package com.net.xpay.core.utils;


import com.beust.jcommander.internal.Lists;
import com.google.common.base.Strings;

import java.util.List;

public class BankUtil {

    /**
     * 验证银行卡卡号是否有效
     *
     * @param cardNo 银行卡号
     * @return 是否有效 true有效 false无效
     */
    public static boolean isValid(String cardNo) {
        if (cardNo == null) {
            return false;
        }
        if (Strings.isNullOrEmpty(cardNo)) {
            return false;
        }
        if (cardNo.contains(" ")) {
            return false;
        }
        List<Integer> validLens = Lists.newArrayList(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24);
        if (!validLens.contains(cardNo.length())) {
            return false;
        }

        return true;
    }
}
